package cucumber.demo.steps;

import cucumber.api.PendingException;
import cucumber.api.java.zh_cn.假如;
import cucumber.api.java.zh_cn.当;
import cucumber.api.java.zh_cn.而且;
import cucumber.api.java.zh_cn.那么;
import mail.deom.page.Actions.ActionsEmail;
import mail.deom.page.Actions.Login;
import mail.deom.page.LoginPage;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.Assert;

/**
 * Created by Administrator on 2016/11/1.
 */
public class Steps {

    public static WebDriver driver;

    @假如("^我打开\"(.*?)\"网站$")
    public void openBrowser(String url) {
        ActionsEmail actionsEmail = new ActionsEmail();
        actionsEmail.openBrowser();
        driver.get(url);
    }
//    @当("^我在用户框输入\"(.*?)\"$")
//    public void sendkeyUsernam(String username){
//        driver.switchTo().frame("x-URS-iframe");
//        driver.findElement(By.name("email")).sendKeys(username);
//    }
//    @而且("^密码输入框输入\"(.*?)\"$")
//    public void sendkeyPassword(String password){
//        driver.findElement(By.name("password")).sendKeys(password);
//    }

    @当("^我点击登录按钮$")
    public void clickLogin(){
        // Write code here that turns the phrase above into concrete actions
        driver.findElement(LoginPage.loginButton).click();
    }


    @那么("^我登录成功$")
    public void loginSuccess(){
        // Write code here that turns the phrase above into concrete actions
        Assert.assertTrue(true);
    }

    @那么("^我登录失败$")
    public void loginFail(){
        // Write code here that turns the phrase above into concrete actions
        Assert.assertFalse(false);
    }

    @假如("^我用用户名\"(.*?)\",密码\"(.*?)\"登录$")
    public void login(String username, String password) {
        // Write code here that turns the phrase above into concrete actions
        Login login = new Login();
        login.loginE(username,password);
    }
}
